package com.no.pokerclub.metamodel.beans;

import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.OneToMany;

import org.hibernate.annotations.Cascade;

import com.no.pokerclub.core.beans.BaseBean;
import com.no.pokerclub.metamodel.Membership;
import com.no.pokerclub.metamodel.User;

@Entity
public class UserBean extends BaseBean implements User {
	private String name;
	private String username;
	private String password;
	private List<Membership> memberships;

	@Basic
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	@OneToMany(mappedBy="user",
			cascade = {CascadeType.ALL},
			targetEntity=MembershipBean.class)
	@Cascade({org.hibernate.annotations.CascadeType.ALL, 
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN} )
	public List<Membership> getMemberships() {
		return memberships;
	}

	public void setMemberships(List<Membership> memberships) {
		this.memberships = memberships;
	}

}
